package game

import (
	"FlyFight/Internal/cheese"
	"log"

)


func (gamer *Gamer)AnalyzeRead(g *Game){

	conn:=gamer.Conn
	uid:=gamer.Uid

	for { 
		var commend Commend
		err:= conn.ReadJSON(&commend)
		if err!=nil {
			log.Println("read json error:",err)
			break
		}
		switch commend.Order {
		case uint8(move):
			log.Println("move")
		case uint8(message):
			log.Println("message")
		case uint8(addcheese):{
			g.Gamers[uint32(uid)].AddCheese(cheese.KillGod,1,1,g)
		}
		case uint8(blood):
			log.Println("blood")
		case uint8(ready):
			log.Println("ready")
		case uint8(newturn):
			g.NextTurn()	
		default:
			log.Println("unknow order")
	}

	}
	conn.Close()
}